//
//  ThePartyDetailController.m
//  PASystem
//
//  Created by 刘沿 on 16/9/23.
//  Copyright © 2016年 czd. All rights reserved.
//

#import "ThePartyDetailController.h"
#import "ThePartyDetailModel.h"
#import "PartyDetailCell.h"
#import "UILabel+time.h"

@interface ThePartyDetailController ()<UITableViewDataSource,UITableViewDelegate>

@property (nonatomic,strong) UITableView *tab;
@property (nonatomic,strong) NSMutableArray *dataArray;

@end

@implementation ThePartyDetailController

static NSString *const reuseID = @"PartyDetailCell";

- (NSMutableArray *)dataArray{
    if (!_dataArray) {
        _dataArray = [NSMutableArray array];
    }
    return _dataArray;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor colorWithRed:241/255.0 green:242/255.0 blue:243/255.0 alpha:1];
    [self loadData];

    UITableView *tab = [[UITableView alloc] init];
    self.tab = tab;
    self.tab.dataSource = self;
    self.tab.delegate = self;
    tab.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:tab];
    [tab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view.mas_top).mas_offset(10);
        make.left.equalTo(self.view.mas_left).mas_offset(10);
        make.right.equalTo(self.view.mas_right).mas_offset(-10);
        make.bottom.equalTo(self.view.mas_bottom).mas_offset(-60);
    }];
}

- (void)loadData{
    
    NSString * userId = [[NSUserDefaults standardUserDefaults]objectForKey:@"userId"];
    NSString * pwdId = [[NSUserDefaults standardUserDefaults]objectForKey:@"pwdId"];
    NSString * userHumber = [[NSUserDefaults standardUserDefaults]objectForKey:@"userHumber"];
    
    NSString *json = [NSString stringWithFormat:@"{'action': dyxxMch,'service': PartydeptService, 'userName':'%@','password':'%@', 'vaueJson':'{userid :%@,id:%@}'}",userId,pwdId,userHumber,self.ID];
    
    NSArray * array = @[@{@"arg0":json}];
    
    
    [HttpTools requestWithURL:BaseURL arrays:array method:Basemethod success:^(id JSON) {
        
        NSDictionary *dict = JSON[@"reason"];
    
        if (dict) {
            NSDictionary *dict2 = dict[@"attrs"];
            ThePartyDetailModel *model = [ThePartyDetailModel mj_objectWithKeyValues:dict2];
            [self.dataArray addObject:model];
        }
        [self.tab reloadData];
    } failure:^(NSError *error) {
        
    }];
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 35;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    ThePartyDetailModel *model = self.dataArray.firstObject;
    
    PartyDetailCell *cell = [tableView dequeueReusableCellWithIdentifier:reuseID];

    if (cell == nil) {
        cell = [PartyDetailCell WithPartyDetailCell];
    }
    
    if (indexPath.row == 0 ) {
        cell.titleLabel.text = @"姓名：";
        cell.desLabel.text = model.NOWNAME;
    }else if (indexPath.row == 1){
    
        cell.titleLabel.text = @"曾用名：";
        cell.desLabel.text = model.OLDNAME;

    }else if (indexPath.row == 2){
    
        cell.titleLabel.text = @"出生日期：";
        NSString *str = [UILabel withTimeStr:model.BIRTHDAY];
        
        cell.desLabel.text = str;

    }else if (indexPath.row == 3){
        
        cell.titleLabel.text = @"性别：";
        if ([model.SEX isEqualToString:@"1"]) {
            cell.desLabel.text = @"男";
        }else{
            cell.desLabel.text = @"女";

        }
        
    }else if (indexPath.row == 4){
        
        cell.titleLabel.text = @"民族：";
        cell.desLabel.text = model.NATION;
        
    }else if (indexPath.row == 5){
        
        cell.titleLabel.text = @"籍贯：";
        cell.desLabel.text = model.REGISTER;
        
    }else if (indexPath.row == 6){
        
        cell.titleLabel.text = @"出生地：";
        cell.desLabel.text = model.BADDRESS;
        
    }else if (indexPath.row == 7){
        
        cell.titleLabel.text = @"健康状况：";
        cell.desLabel.text = model.HEALTH;
        
    }else if (indexPath.row == 8){
        
        cell.titleLabel.text = @"家庭出身：";
        if ([model.FAMILY isEqualToString:@"1"]) {
            cell.desLabel.text = @"工人";
            
        }else if ([model.FAMILY isEqualToString:@"2"]){
            cell.desLabel.text = @"农民";

        }else if ([model.FAMILY isEqualToString:@"3"]){
            cell.desLabel.text = @"干部";

        }else if ([model.FAMILY isEqualToString:@"4"]){
            cell.desLabel.text = @"职员";

        }else{
        
            cell.desLabel.text = @"其它";

        }
        
    }else if (indexPath.row == 9){
        
        cell.titleLabel.text = @"婚姻状况：";
        if ([model.MARRIAGE isEqualToString:@"1"]) {
            cell.desLabel.text = @"单身";
            
        }else if ([model.MARRIAGE isEqualToString:@"2"]){
            cell.desLabel.text = @"已婚";
            
        }else if ([model.MARRIAGE isEqualToString:@"3"]){
            cell.desLabel.text = @"离异";
            
        }else if ([model.MARRIAGE isEqualToString:@"4"]){
            cell.desLabel.text = @"丧偶";
        }
        
    }else if (indexPath.row == 10){
        
        cell.titleLabel.text = @"工作时间(年)：";
        cell.desLabel.text = model.WORKTIME;
        
    }else if (indexPath.row == 11){
        
        cell.titleLabel.text = @"个人身份：";
        if ([model.IDENTITY isEqualToString:@"1"]) {
            cell.desLabel.text = @"公务员";
            
        }else if ([model.IDENTITY isEqualToString:@"2"]){
            cell.desLabel.text = @"企事业单位管理";
            
        }else if ([model.IDENTITY isEqualToString:@"3"]){
            cell.desLabel.text = @"专业技术人员";
            
        }else if ([model.IDENTITY isEqualToString:@"4"]){
            cell.desLabel.text = @"工勤人员";
            
        }else{
            
            cell.desLabel.text = @"其它人员";
            
        }
    }else if (indexPath.row == 12){
        
        cell.titleLabel.text = @"学历：";
        cell.desLabel.text = model.EDUCATION;
        
    }else if (indexPath.row == 13){
        
        cell.titleLabel.text = @"学位：";
        cell.desLabel.text = model.EDUCATION;
        
    }else if (indexPath.row == 14){
        
        cell.titleLabel.text = @"专业：";
        cell.desLabel.text = model.MAJOR;
        
    }else if (indexPath.row == 15){
        
        cell.titleLabel.text = @"毕业学校：";
        cell.desLabel.text = model.UNIVERSITY;
        
    }else if (indexPath.row == 16){
        
        cell.titleLabel.text = @"毕业日期：";
        cell.desLabel.text = model.EDUCATION;
        
    }else if (indexPath.row == 17){
        
        cell.titleLabel.text = @"工作日期：";
        NSString *str = [UILabel withTimeStr:model.WORKDAY];
        
        cell.desLabel.text = str;
        
    }else if (indexPath.row == 18){
        
        cell.titleLabel.text = @"职务名称：";
        cell.desLabel.text = model.JOB;
        
    }else if (indexPath.row == 19){
        
        cell.titleLabel.text = @"技术职务：";
        cell.desLabel.text = model.TECHNOLOGY;
        
    }else if (indexPath.row == 20){
        
        cell.titleLabel.text = @"进单位日期：";
        NSString *str = [UILabel withTimeStr:model.COMINGDAY];
        cell.desLabel.text = str;
        
    }else if (indexPath.row == 21){
        
        cell.titleLabel.text = @"手机号码：";
        cell.desLabel.text = model.TEL;
        
    }else if (indexPath.row == 22){
        
        cell.titleLabel.text = @"邮编：";
        cell.desLabel.text = model.CODE;
        
    }else if (indexPath.row == 23){
        
        cell.titleLabel.text = @"Email：";
        cell.desLabel.text = model.EMAIL;
        
    }else if (indexPath.row == 24){
        
        cell.titleLabel.text = @"入党时间：";
        NSString *str = [UILabel withTimeStr:model.PARTYTIME];
        cell.desLabel.text = str;
        
    }else if (indexPath.row == 25){
        
        cell.titleLabel.text = @"入党介绍人：";
        cell.desLabel.text = model.PARTYINTRODUCE;
        
    }else if (indexPath.row == 26){
        
        cell.titleLabel.text = @"转正时间：";
        NSString *str = [UILabel withTimeStr:model.REGULARTIME];
        cell.desLabel.text = str;
        
    }else if (indexPath.row == 27){
        
        cell.titleLabel.text = @"入党所在党组织：";
        cell.desLabel.text = model.ORGANIZATION;
        
    }else if (indexPath.row == 28){
        
        cell.titleLabel.text = @"退休时间：";
        NSString *str = [UILabel withTimeStr:model.RETIRETIME];
        cell.desLabel.text = str;
        
    }else if (indexPath.row == 29){
        
        cell.titleLabel.text = @"转正情况：";
        if ([model.REGULARSITUATION isEqualToString:@"1"]) {
            cell.desLabel.text = @"按时转正";
        }else{
        cell.desLabel.text = @"未按时转正";
        }
        
    }else if (indexPath.row == 30){
        
        cell.titleLabel.text = @"离职原因：";
        cell.desLabel.text = model.QUIT;
        
    }else if (indexPath.row == 31){
        
        cell.titleLabel.text = @"身份证：";
        cell.desLabel.text = model.IDCODE;
        
    }else if (indexPath.row == 32){
        
        cell.titleLabel.text = @"户籍所在地：";
        cell.desLabel.text = model.REGISTERADD;
        
    }else if (indexPath.row == 33){
        
        cell.titleLabel.text = @"现居住地址：";
        cell.desLabel.text = model.ADDRESS;
        
    }else if (indexPath.row == 34){
        
        cell.titleLabel.text = @"备注：";
        cell.desLabel.text = model.REMARKS;
        
    }
    
    return cell;
    
}


@end











